package com.letv.core.contentprovider;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class UserInfoDb extends SQLiteOpenHelper {
    /**
     * 数据库版本号
     * */
    private static final int DATABASE_VERSION = 1;

    /**
     * 数据库名称
     */
    public static final String DATABASE_NAME = "userinfoshare.db";

    public static final String TABLE_NAME = "userinfo";
    public static final String USER_ID = "userId";
    public static final String TOKEN = "token";
    public static final String SHARE_USER_ID = "shareUserId";
    public static final String SHARE_TOKEN = "shareToken";

    public UserInfoDb(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        createTable(db);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("drop table if exists " + TABLE_NAME);
        createTable(db);
    }

    /**
     * 创建广告表
     */
    private void createTable(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE " + TABLE_NAME + "(" + USER_ID + " TEXT PRIMARY KEY," + TOKEN + " TEXT," + SHARE_USER_ID + " TEXT,"+ SHARE_TOKEN + " TEXT"+ ");");
    }

}
